package ru.amse.tsyganov.jumleditor.commands;

import ru.amse.tsyganov.jumleditor.model.StateVertex;
import ru.amse.tsyganov.jumleditor.model.Transition;
import ru.amse.tsyganov.jumleditor.view.TransitionView;

/*package*/ class NewTransitionCommand extends Command {
	
	private final StateVertex sourceStateVertex;
	private final StateVertex targetStateVertex;
	
	private TransitionView<Transition> transitionView;
	
	public NewTransitionCommand(
			TransitionView<Transition> transitionView) {
		
		this.transitionView = transitionView;
		sourceStateVertex = transitionView.getModel().getSource();
		targetStateVertex = transitionView.getModel().getTarget();
	}
	
	@Override
	public void execute() {
		transitionView.getModel().setSource(sourceStateVertex);
		transitionView.getModel().setTarget(targetStateVertex);
	}

	@Override
	public void unexecute() {
		transitionView.getModel().removeBindings();
	}

	@Override
	public void dispose() {
	}

}
